//
// CVideoRendererFilter.cpp
//

/*-----------------------------------------------------*\
			HQ Tech, Make Technology Easy!       
 More information, please go to http://hqtech.nease.net.
/*-----------------------------------------------------*/

#include "stdafx.h"
#include "CVideoRendererFilter.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

GUID CLSID_VMR9 = {
0x51B4ABF3, 0x748F, 0x4E3B, 0xA2, 0x76, 0xC8, 0x28, 0x33, 0x0E, 0x92, 0x6A};

GUID CLSID_VMR7 = {
0x6BC1CFFA, 0x8FC1, 0x4261, 0xAC, 0x22, 0xCF, 0xB4, 0xCC, 0x38, 0xDB, 0x50};

////////////////////////////////////////////////////////////////////////
CVideoRendererFilter::CVideoRendererFilter(IGraphBuilder * inGraph) : 
CDXFilter(inGraph, CLSID_VideoRenderer, "Video Renderer")
{
	mVMRPreferred = FALSE;
}

CVideoRendererFilter::~CVideoRendererFilter(void)
{
}

BOOL CVideoRendererFilter::CreateFilter(void)
{
	if (!mVMRPreferred)
	{
		mClsid = CLSID_VideoRenderer;
		return CDXFilter::CreateFilter();
	}
	else
	{
		mClsid = CLSID_VMR9;
		BOOL pass = CDXFilter::CreateFilter();
		if (!pass)
		{
			mClsid = CLSID_VMR7;   // Only available on XP
			pass = CDXFilter::CreateFilter();
		}
		if (!pass)
		{
			mClsid = CLSID_VideoRenderer;
			pass = CDXFilter::CreateFilter();
		}
		return pass;
	}
}

void CVideoRendererFilter::SetVMRPreferred(BOOL inPreferred)
{
	mVMRPreferred = inPreferred;
}

IPin * CVideoRendererFilter::GetInputPin(void)
{
	if (mClsid == CLSID_VideoRenderer)
	{
		return CDXFilter::GetPin(TRUE, "Input");
	}
	else
	{
		return CDXFilter::GetPin(TRUE, "VMR Input0");
	}
}
